package br.edu.fatec.ratoninja;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.view.WindowManager;

public class GameActivity extends Activity {

	private static final String TAG = "RatoNinja::GameActivity";
	public static final int INVALIDADE_CANVAS = 10001;
	
	private GameView gameView;
	private Handler handler;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
	
		//instanciamos a gameView
		gameView = new GameView(this);
		setContentView(gameView);

		handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				if (msg.what == INVALIDADE_CANVAS) {
					gameView.invalidate();
				}
				super.handleMessage(msg);
			}
		};

		gameView.setCallbackHandler(handler);

		Thread gameThread = new Thread(gameView);
		gameThread.setDaemon(true);
		gameThread.start();
	}
}